<admintpl file="header"/></head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('afterloan/index',array('type'=>$type))}">贷后操作列表</a></li>
        <li class="active"><a>收款登记</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form" action="{:U('afterloan/after_loan_rev')}" method="post">
        <fieldset>
            <div class="tabbable">
                <div class="tab-content">
                    <!--内容开始-->
                    <div class="control-group">
                        <label class="control-label">订单号</label>
                        <div class="controls">
                            <input type="text" disabled value="{$order['order_id']}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">订单状态</label>
                        <div class="controls">
                            <php> $statusModel = new \User\Model\ReportCurrentOrders();</php>
                            <input type="text" disabled value="{:$statusModel->getStatusText($order['status'])}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">借条金额</label>
                        <div class="controls">
                            <input type="text" disabled value="{$order['amount']}元 / {$order['stages']}期"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">手机</label>
                        <div class="controls">
                            <input type="text" disabled value="{$user['mobile']}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">用户</label>
                        <div class="controls">
                            <input type="text" disabled value="{$user['name']}"/>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">操作记录</label>
                        <div class="controls">
                            <table class="table table-bordered">
                                <tr>
                                    <th>登记日期</th>
                                    <th>登记人</th>
                                    <th>逾期平台</th>
                                    <th>收款金额</th>
                                    <th>是否解套</th>
                                    <th>解套平台</th>
                                    <th>解套金额</th>
                                    <th>是否续期</th>
                                    <th>续期金额</th>
                                    <th>用户状态</th>
                                    <th>是否核对</th>
                                </tr>
                                <foreach name="list" item="vo">
                                    <tr>
                                        <td>{$vo['operation_date']}</td>
                                        <td>{$admins[$vo['principal']]}</td>
                                        <td>
                                            <php>echo \User\Model\LoanOperationLogModel::getPlatformText($vo['platform']);</php>
                                        </td>
                                        <td style="padding: 0;border-top: 0;">
                                            <ul class="list-group" style="border: 0;padding: 0;margin: 0;">
                                                <li class="list-group-item">
                                                    <span class="badge">{$vo.total_system_amount}</span>
                                                    系统
                                                </li>
                                                <li class="list-group-item">
                                                    <span class="badge">{$vo.total_wechat_amount}</span>
                                                    <span style="color:green">微信</span>
                                                </li>
                                                <li class="list-group-item">
                                                    <span class="badge">{$vo.total_alipay_amount}</span>
                                                    <span style="color:blue">支付宝</span>
                                                </li>
                                                <li class="list-group-item">
                                                    <span class="badge">{$vo.total_bank_amount}</span>
                                                    <span style="color:#ff8216">银行转账</span>
                                                </li>
                                                <li class="list-group-item">
                                                    <span class="badge">{$vo.total_rev_amount}</span>
                                                    <span style="color:darkred">小计</span>
                                                </li>
                                            </ul>
                                        </td>
                                        <td>
                                            <php>echo \User\Model\LoanOperationLogModel::getIsReliefText($vo['is_relief']);</php>
                                        </td>
                                        <td>{$vo['relief_platform_txt']}</td>
                                        <td>{$vo['relief_amount']}</td>
                                        <td>
                                            <php>echo \User\Model\LoanOperationLogModel::getIsRenewalText($vo['is_renewal']);</php>
                                        </td>
                                        <td>
                                            {$vo['renewal_amount']}
                                        </td>
                                        <td>
                                            <php>echo \User\Model\LoanOperationLogModel::getUserStatusText($vo['user_status']);</php>
                                        </td>
                                        <td>
                                            <php>echo \User\Model\LoanOperationLogModel::getIsCheckText($vo['is_check']);</php>
                                        </td>
                                    </tr>
                                </foreach>
                            </table>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label"> <b style="color:red;">* </b><strong>收款方式</strong> </label>
                        <div class="controls checkbox-inline">
                            &nbsp;<input type="checkbox" class="check_pay_way" name="options[pay_way][0]" value="0" checked="checked">&nbsp;系统 &nbsp;<input type="checkbox" class="check_pay_way" name="options[pay_way][1]" value="1">&nbsp;微信 &nbsp;<input type="checkbox" class="check_pay_way" name="options[pay_way][2]" value="2">&nbsp;支付宝 &nbsp;<input type="checkbox" class="check_pay_way" name="options[pay_way][3]" value="3">&nbsp;银行转账
                        </div>
                        <script>
                            $('.check_pay_way').click(function () {
                                $('.pay_' + $(this).val()).fadeToggle();
                            });
                        </script>
                    </div>
                    <div class="control-group pay_0" style="display: block;">
                        <label class="control-label">系统实收</label>
                        <div class="controls">
                            <input type="text" name="options[rev_amount_0]" class="just_can_number" size="11" placeholder="请输入数字"/><span style="color: #b4b4b4">&nbsp;备注：表示用户自己充值</span>
                        </div>
                    </div>
                    <div class="control-group pay_1" style="display: none;">
                        <label class="control-label">微信实收</label>
                        <div class="controls">
                            <input type="text" name="options[rev_amount_1]" class="just_can_number" size="11" placeholder="请输入数字"/>
                            <b style="color:red;">* </b> <span>&nbsp;&nbsp;收款人&nbsp;&nbsp;</span>
                            <select name="options[rev_admin_id_1]">
                                <php>$wechatRevAdminList = \User\Model\LoanReceivedLogModel::getWechatRevAdminList()</php>
                                <foreach name="wechatRevAdminList" item="vo">
                                    <option value="{$vo.id}">{$vo.user_login}</option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <div class="control-group pay_2" style="display: none;">
                        <label class="control-label">支付宝实收</label>
                        <div class="controls">
                            <input type="text" name="options[rev_amount_2]" class="just_can_number" size="11" placeholder="请输入数字"/>
                            <b style="color:red;">* </b> <span>&nbsp;&nbsp;收款人&nbsp;&nbsp;</span>
                            <select name="options[rev_admin_id_2]">
                                <php>$alipayRevAdminList = \User\Model\LoanReceivedLogModel::getAlipayRevAdminList()</php>
                                <foreach name="alipayRevAdminList" item="vo">
                                    <option value="{$vo.id}">{$vo.user_login}</option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <div class="control-group pay_3" style="display: none;">
                        <label class="control-label">银行转账</label>
                        <div class="controls">
                            <input type="text" name="options[rev_amount_3]" class="just_can_number" size="11" placeholder="请输入数字"/>
                            <b style="color:red;">* </b> <span>&nbsp;&nbsp;收款人&nbsp;&nbsp;</span>
                            <select name="options[rev_admin_id_3]">
                                <php>$bankTransferAdminList = \User\Model\LoanReceivedLogModel::getBankTransferAdminList()</php>
                                <foreach name="bankTransferAdminList" item="vo">
                                    <option value="{$vo.id}">{$vo.user_login}</option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">登记日期</label>
                        <div class="controls">
                            <input type="text" class="js-date" name="options[operation_date]" value="{:date('Y-m-d')}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">是否解套</label>
                        <div class="controls">
                            <select name="options[is_relief]">
                                <option value="0">否</option>
                                <option value="1">是</option>
                            </select>
                            <script>
                                $('select[name="options[is_relief]"]').change(function () {
                                    if (parseInt($(this).val()) === 1) {
                                        $('.relief').fadeIn();
                                    } else {
                                        $('.relief').fadeOut();
                                    }
                                });
                            </script>
                        </div>
                    </div>
                    <div class="control-group relief" style="display: none;">
                        <label class="control-label">解套平台</label>
                        <div class="controls">
                            <input type="text" name="options[relief_platform_txt]"/>
                        </div>
                    </div>
                    <div class="control-group relief" style="display: none;">
                        <label class="control-label">解套金额</label>
                        <div class="controls">
                            <input type="text" class="just_can_number" name="options[relief_amount]" placeholder="请输入数字"/>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">是否续期</label>
                        <div class="controls">
                            <select name="options[is_renewal]">
                                <option value="0">否</option>
                                <option value="1">是</option>
                            </select>
                            <script>
                                $('select[name="options[is_renewal]"]').change(function () {
                                    if (parseInt($(this).val()) === 1) {
                                        $('.renewal').fadeIn();
                                    } else {
                                        $('.renewal').fadeOut();
                                    }
                                });
                            </script>
                        </div>
                    </div>
                    <div class="control-group renewal" style="display: none;">
                        <label class="control-label">实收续期费</label>
                        <div class="controls">
                            <input type="text" class="just_can_number" name="options[renewal_amount]" placeholder="请输入数字"/><span style="color: #b4b4b4">&nbsp;备注：此处续期费，含于上方收款金额中</span>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">用户状态</label>
                        <div class="controls">
                            <select name="options[user_status]">
                                <option value="0">待收</option>
                                <option value="1">完结</option>
                            </select>
                        </div>
                    </div>
                    <!--内容结束-->
                </div>
            </div>
            <div class="form-actions">
                <button class="btn btn-primary js-ajax-submit" type="submit" data-types='1' data-action="{:U('afterloan/after_loan_rev',['id'=>I('get.id')])}" data-msg='确认登记?' data-subcheck="true">确认登记</button>
            </div>
        </fieldset>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript">
    var ajaxForm_list = $('form.js-ajax-form');
    if (ajaxForm_list.length) {
        Wind.use('ajaxForm', 'artDialog', function () {
            $('button.js-ajax-submit').bind('click', function (e) {
                e.preventDefault();
                var btn = $(this);
                var form = btn.parents('form.js-ajax-form');
                //批量操作 判断选项
                if (btn.data('subcheck')) {
                    btn.parent().find('span').remove();
                    var msg = btn.data('msg');
                    if (msg) {
                        art.dialog({
                            id: 'warning',
                            icon: 'warning',
                            content: btn.data('msg'),
                            cancelVal: "{:L('CLOSE')}",
                            cancel: function () {
                            },
                            button: [{
                                name: "{:L('OK')}",
                                callback: function () {
                                    ajaxSubmit(btn.data('types'));
                                },
                                focus: true
                            }]
                        });
                    } else {
                        btn.data('subcheck', false);
                        btn.click();
                    }
                    return false;
                }
            });
        });
    }

    function ajaxSubmit(type) {
        var btn = $('button.js-ajax-submit');
        var form = btn.parents('form.js-ajax-form');
        form.ajaxSubmit({
            url: type ? btn.data('action') : form.attr('action'),
            //按钮上是否自定义提交地址(多按钮情况)
            dataType: 'json',
            beforeSubmit: function (arr, $form, options) {
                var tx = '提交';
                //按钮文案、状态修改
                btn.text(tx + '中...').attr('disabled', true).addClass('disabled');
            },
            success: function (data, statusText, xhr, $form) {
                //按钮文案、状态修改
                btn.removeClass('disabled').parent().find('span').remove();
                if (data.state === 'success') {
                    $('<span class="tips_success">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('slow').delay(1000).fadeOut(function () {
                        if (data.referer) {
                            //返回带跳转地址
                            if (window.parent.art) {
                                //iframe弹出页
                                window.parent.location.href = data.referer;
                            } else {
                                window.location.href = data.referer;
                            }
                        } else {
                            if (window.parent.art) {
                                reloadPage(window.parent);
                            } else {
                                //刷新当前页
                                reloadPage(window);
                            }
                        }
                    });
                } else if (data.state === 'fail') {
                    $('<span class="tips_error">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('fast');
                    btn.text('确认登记').removeProp('disabled').removeClass('disabled');
                }
            }
        });
    }
</script>
<script>
    $(function () {
        $('.just_can_number').keyup(function () {
            var obj = this;
            obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
            obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
        });
    });
</script>
</body></html>